package linwen.wang.redis.jedis;

import org.junit.Test;
import redis.clients.jedis.Jedis;

/**
 * @ClassName JedisList
 * @Description
 * @Author lin
 * @Date 2022/3/2 下午9:38
 * @Version V1.0
 */
public class JedisList {
    // List
    @Test
    public void test(){
        Jedis jedis = new Jedis();
        jedis.flushDB();
        //从列表头部插入
        jedis.lpush("l1", "a","b","c");
        //从列表尾部插入
        jedis.rpush("l1", "d","e");
        //返回列表中所有值
        System.out.println(jedis.lrange("l1", 0, -1));
        //返回列表长度
        System.out.println(jedis.llen("l1"));
        //从列表头部移除一个元素并返回
        System.out.println(jedis.lpop("l1"));
        //从列表尾部移除一个元素并返回
        System.out.println(jedis.rpop("l1"));
        jedis.close();
    }
}
